package com.xj.demo.config;

import org.elasticsearch.client.RestHighLevelClient;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.data.elasticsearch.client.ClientConfiguration;
import org.springframework.data.elasticsearch.client.RestClients;
import org.springframework.data.elasticsearch.config.AbstractElasticsearchConfiguration;
import org.springframework.data.elasticsearch.repository.config.EnableElasticsearchRepositories;

/**
 * <p> RestHighLevelClient配置 </p>
 *
 * @author xujj
 * @description
 * @date 2024/4/6 16:15
 */
@Configuration
@EnableElasticsearchRepositories(basePackages = "com.xj.demo.repository")
public class RestClientConfig extends AbstractElasticsearchConfiguration {

    @Override
    @Bean
    public RestHighLevelClient elasticsearchClient() {

        final ClientConfiguration clientConfiguration = ClientConfiguration.builder()
                .connectedTo("114.132.93.125:9200")
                .build();

        return RestClients.create(clientConfiguration).rest();
    }
}
